package com.wenfs.demo.util.result;

import com.wenfs.demo.entity.Result;

/**
 * @author wefashe
 */
public class ResultHandler {

  /**
   * 操作成功
   * @return
   */
  public static Result success() {
    return success(null);
  }

  /**
   * 操作成功
   * @param object
   * @return
   */
  public static Result success(Object object) {
    Result result = new Result();
    result.setErrorCode("0");
    result.setData(object);
    return result;
  }

  /**
   * 操作失败
   * @param errorCode
   * @param errorMsg
   * @return
   */
  public static Result error(String errorCode, String errorMsg) {
    Result result = new Result();
    result.setErrorCode(errorCode);
    result.setErrorMsg(errorMsg);
    return result;
  }

  /**
   * 操作失败
   * @param enums
   * @return
   */
  public static Result error(ResultEnums enums) {
    Result result = new Result();
    result.setErrorCode(enums.getErrorCode());
    result.setErrorMsg(enums.getErrorMsg());
    return result;
  }
}
